import { constantRoutes } from '@/router'
import store from '@/store'

const state = {
  routes: []
}

const mutations = {
  SET_ROUTES: (state, routes) => {
    state.routes = constantRoutes.concat(routes)
  }
}

const actions = {
  generateRoutes({ commit }, homePage) {
    return new Promise(resolve => {
      if(homePage == '工作站'){
        commit('SET_ROUTES', store.state.user.routerListA);
      }else{
        commit('SET_ROUTES', store.state.user.routerListB);
      }
      resolve(homePage);
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
